﻿using System;
using System.Security.Cryptography;
using System.Text;

namespace CryptoModule
{
    public class MD5Crypto
    {
        public static String MD5Encode(String source)
        {
            Encoding enc = new ASCIIEncoding();
            MD5 md5 = new MD5CryptoServiceProvider();
            byte[] bToConvert = md5.ComputeHash(enc.GetBytes(source));
            string result = "";
            for (int i = 0; i < 16; i++)
            {
                result += String.Format("{0:x02}", bToConvert[i]);
            }
            return result;
        }

        public static byte[] MD5Encode(byte[] source)
        {
            MD5 md5 = new MD5CryptoServiceProvider();
            return md5.ComputeHash(source);
        }
    }
}